package acwing;
/**
 * @Project : AlgorithmLearning
 * @Package : ACWing.QuestionsPractice
 * @File : Q4943.java
 * @Author : WangRuoyu
 * @Date : 2023/4/2 19:55
 */

import java.io.*;
import java.util.LinkedList;
import java.util.Queue;

public class Q4943 {
    static int n;
    static int m;
    static int k;
    static int x1;
    static int x2;
    static int y1;
    static int y2;
    static boolean[][] st;
    static int[][] maze;
    static int[][] d = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] words = br.readLine().split(" ");
        n = Integer.parseInt(words[0]);
        m = Integer.parseInt(words[1]);
        k = Integer.parseInt(words[2]);
        maze = new int[n + 1][m + 1];
        st = new boolean[n + 1][m + 1];

        for (int i = 1; i <= n; ++i) {
            String line = br.readLine();
            for (int j = 1; j <= m; ++j) {
                maze[i][j] = line.charAt(j - 1);
            }
        }

        words = br.readLine().split(" ");
        x1 = Integer.parseInt(words[0]);
        y1 = Integer.parseInt(words[1]);
        x2 = Integer.parseInt(words[2]);
        y2 = Integer.parseInt(words[3]);

        Queue<int[]> q = new LinkedList<>();
        q.add(new int[]{x1, y1, 0, -1, 0});
        st[x1][y1] = true;
        int res = -1;
        while (!q.isEmpty()) {
            int[] point = q.poll();
            if (point[0] == x2 && point[1] == y2) {
                res = point[2];
                break;
            }
            for (int i = 0; i < 4; ++i) {
                int[] newp = new int[5];
                newp[0] = point[0] + d[i][0];
                newp[1] = point[1] + d[i][1];
                newp[3] = i;
                if (newp[0] >= 1 && newp[0] <= n && newp[1] >= 1 && newp[1] <= m && maze[newp[0]][newp[1]] == '.' && !st[newp[0]][newp[1]]) {
                    if (newp[3] != point[3]) {
                        newp[2] = point[2] + 1;
                        newp[4] = 1;
                    } else {
                        if (point[4] >= k) {
                            newp[2] = point[2] + 1;
                            newp[4] = 1;
                        } else {
                            newp[2] = point[2];
                            newp[4] = point[4]+1;
                        }
                    }
                    q.add(newp);
                    st[newp[0]][newp[1]] = true;
                }
            }
        }
        System.out.println(res);
    }
}
